﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Reflection;

namespace Novel.Entity
{
    public enum EnumStatus : byte
    {
        /// <summary>
        /// 无效
        /// </summary>
        [Description("无效")]
        NoValid = 0,
        /// <summary>
        /// 有效
        /// </summary>
        [Description("有效")]
        Valid = 1

    }
    public class EntityBase
    {
        public static T Instance<T>() where T : EntityBase, new()
        {
            return new T();
        }

        public T Convert<T>() where T : new()
        {
            PropertyInfo[] properties = this.GetType().GetProperties();
            T t = new T();
            foreach (PropertyInfo property in properties)
            {
                try
                {
                    if (property.GetCustomAttributes(typeof(Attribute), true).Length == 0)
                        property.SetValue(t, property.GetValue(this, null), null);
                }
                catch { }
            }
            return t;
        }
    }
}
